package com.etoak.service.impl;

import com.etoak.entity.OrderItem;
import com.etoak.mapper.DishesMapper;
import com.etoak.mapper.OrderItemMapper;
import com.etoak.service.FoodListService;
import com.etoak.service.OrderItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.etoak.vo.DishesVO;
import com.etoak.vo.OrderItemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author et2403
 * @since 2024-08-16
 */
@Service
public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem> implements OrderItemService {

    @Autowired
    FoodListService foodListService;
    @Override
    public List<OrderItemVO> getListItem(String orderNo) {
        String detail = "";
        List<OrderItemVO> itemlist = baseMapper.getListItem(orderNo);
        for (OrderItemVO item : itemlist) {
            DishesVO d = foodListService.getFoodList(item.getDishesId());
            detail = d.getMainName()+":"+d.getMainNum()+"g;"+d.getMinorName()+":"+d.getMinorNum()+"g;"+d.getSeasoningName()+":"+d.getSeasoningNum()+"g;";
            item.setDetail(detail);
            item.setName(d.getName());
        }
        return itemlist;
    }
}
